package orderServlet;
import java.awt.*;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import orderServlet.orderBean;

public class AllorderList {
    java.sql.Connection conn = null;
    String strConn;
    java.sql.Statement sqlStmt = null;
    ResultSet sqlRst = null;
    public List allorder() {
        List<orderBean> list = new ArrayList<>();
        try {
            Class.forName("org.h2.Driver");
            conn = java.sql.DriverManager.getConnection("jdbc:h2:~/jpa-demo-db;MODE=MYSQL;DB_CLOSE_DELAY=-1", "sa", "sa");
            sqlStmt = conn.createStatement();
            String sql = "select * from order1 ";
            sqlRst = sqlStmt.executeQuery(sql);
            while (sqlRst.next()) {
                String ono = sqlRst.getString("ono");
                String name = sqlRst.getString("name");
                String phone = sqlRst.getString("phone");
                String rno = sqlRst.getString("rno");
                String de_time = sqlRst.getString("de_time");
                String check_time = sqlRst.getString("check_time");
                int price = sqlRst.getInt("price");
                int pledge = sqlRst.getInt("pledge");
                int count = sqlRst.getInt("count");
                orderBean ob = new orderBean(ono, name, phone, rno, de_time, check_time, price, pledge, count);
                list.add(ob);
            }
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
        return list;
    }
}